import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Switch,Redirect } from 'react-router-dom'
//   NavLink, Link 
import App from './App'
import Admin from './admin'
import Home from './pages/home'
import Buttons from './pages/ui/buttons'
import Nomatch from './pages/nomatch'
import Modals from './pages/ui/modals'
import Loadings from './pages/ui/loadings'
import Notice from './pages/ui/notice'
import Messages from './pages/ui/message'
import Tabs from './pages/ui/tabs'
import Gallery from './pages/ui/gallery'
import Carousel from './pages/ui/carousel'
import FormLogin from './pages/form/login'
import Register from './pages/form/register'
import BasicTable from './pages/table/basicTable'
import HighTable from './pages/table/highTable'
import City from './pages/city'
import Order from './pages/order'
import OrderDetail from './pages/order/detail'
import OrderDetailGD from './pages/order/detail_gd'
import User from './pages/user'
import BikeMap from './pages/map/bikeMap'
import echartsBar from './pages/echarts/bar'
import echartsLine from './pages/echarts/line'
import echartsPie from './pages/echarts/Pie'
import Permission from './pages/permission'
import Rich from './pages/rich'
import Common from './common'
export default class IRouter extends Component {
    render() {
        return (
           <Router>
             <App>
              <Switch>
                <Route path='/common' render={() => 
                  <Common>
                    <Route path='/common/order/detail/:orderId' component={OrderDetailGD}></Route>
                    <Route path='/common/order/detailbd/:orderId' component={OrderDetail}></Route>
                  </Common>
                } />
                <Route path='/' render={() =>
                  //es6 这里写了{}就得写return 不写就直接写结构s
                  <Admin>
                    <Switch>
                      <Route path='/home' component={Home} />
                      <Route path='/ui/buttons' component={Buttons}></Route>
                      <Route path='/ui/modals' component={Modals}></Route>
                      <Route path='/ui/loadings' component={Loadings}></Route>
                      <Route path='/ui/notification' component={Notice}></Route>
                      <Route path='/ui/messages' component={Messages}></Route>
                      <Route path='/ui/tabs' component={Tabs}></Route>
                      <Route path='/ui/gallery' component={Gallery}></Route>
                      <Route path='/ui/carousel' component={Carousel}></Route>
                      <Route path='/form/login' component={FormLogin} />
                      <Route path='/form/reg' component={Register} />
                      <Route path='/table/basic' component={BasicTable} />
                      <Route path='/table/high' component={HighTable} />
                      <Route path='/city' component={City} />
                      <Route path='/order' component={Order} />
                      <Route path='/user' component={User} />
                      <Route path='/bikeMap' component={BikeMap} />
                      <Route path='/charts/bar' component={echartsBar} />
                      <Route path='/charts/line' component={echartsLine} />
                      <Route path='/charts/Pie' component={echartsPie} />
                      <Route path='/permission' component={Permission} />
                      <Route path='/rich' component={Rich} />
                      {/* 这行导致nomatch失效 */}
                      <Redirect to="/home"/>
                      <Route component={Nomatch}></Route>
                    </Switch>
                  </Admin>
                } />

              </Switch>
             </App>
           </Router>
        )
    }
}
